Don't re-trigger Java validation for all opened Java files when a Java file is saved.#546
Conversation
file is saved. Signed-off-by: azerr <azerr@redhat.com>
| JDTMicroProfileProject mpProject = getJDTMicroProfileProject(file); | ||
| if (mpProject != null) { | ||
| // Evict the properties cache | ||
| mpProject.evictConfigSourcesCache(); |
There was a problem hiding this comment.
This code was super annoying because it evicted the config source cache as soon as an application.properties was updated (in other words when a Java file was saved because target/classes/application.properties was updated) or when src/main/resources/application.properties was updated.
| // Create, delete config source file (ex : microprofile-config.properties) | ||
| if (mpProject != null) { | ||
| // Evict the properties cache | ||
| mpProject.evictConfigSourcesCache(); |
There was a problem hiding this comment.
The evict cache of config source is done now only when a config file is created/deleted which is required to rebuild the config files scope.
| } | ||
| } else if (isFileContentChanged(delta)) { | ||
| // Update config source file (ex : microprofile-config.properties) | ||
| generateEvent = mpProject != null ? mpProject.updateConfigSource(file) : true; |
There was a problem hiding this comment.
This case comes from when:
- a Java file is saved, target/application.properties is updated.
- src/main/resources/application.properties is updated.
The mpProject.updateConfigSource(file) returns true only when src/main/resources/application.properties is updated
When application.properties is updated (only for sources), we don't evict the full cache of config sources but just reset the IConfigSource
datho7561
left a comment
There was a problem hiding this comment.
Looks good and makes sense. Thanks, Angelo!
Don't re-trigger Java validation for all opened Java files when a Java file is saved.
This PR avoid sending (type=3 which means configFile changed)
which retriggers validation of Java files when a Java file is saved.
See redhat-developer/vscode-quarkus#1004 (comment)
Before this PR
target/classes/application.propertieswas updatedsrc/main/resources/application.propertiesand one update fromtarget/classes/application.propertiesAfter this PR